#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : aimix
@File    : video_deduplication_worker.py
@IDE     : PyCharm
@Author  : admin
@Date    : 2025/4/21 14:42
"""
import json
import traceback
from PyQt5.QtCore import QThread, pyqtSignal
from core.video.video_deduplication import VideoDeduplication


class VideoDeduplicationQtThread(QThread):
    failed = pyqtSignal(Exception)


    def __init__(self, content, parent=None):
        super(VideoDeduplicationQtThread, self).__init__()
        self.content = content

    def run(self):
        try:
            items = json.loads(self.content)
            video_deduplication = VideoDeduplication(
                input_files=items.get("input_files"),
                output_path=items.get("output_dir"),
                flip_status=items.get("flip_status"),
                speed_up_status=items.get("speed_up_status"),
                extract_frames_status=items.get("extract_frames_status"),
                add_img_overlay_status=items.get("add_img_overlay_status"),
                add_video_overlay_status=items.get("add_video_overlay_status"),
                adjust_video_status=items.get("adjust_video_status"),
                adjust_hsl_status=items.get("adjust_hsl_status"),
                adjust_color_balance_status=items.get("adjust_color_balance_status"),
                **items.get("kwargs")
            )
            video_deduplication.run()
        except Exception as e:
            traceback.print_exc()
            self.failed.emit(e)





